<div class="form-group">
    <label for="datasource_select" class="control-label col-xs-2">数据源连接</label>
    <div class="col-xs-10">
        <select name="datasource_select" class="form-control" id="datasource_select" required
                ng-change="changeSourceLink(dataset_defines.DataServiceMeta.DataSouceLink)"
                ng-options="source.datasource_id as source.datasource_name for source in dataSources"
                ng-model="dataset_defines.DataServiceMeta.DataSouceLink"></select>
    </div>
</div>
<div class="form-group">
    <label class="control-label col-xs-2">数据查询语句</label>
    <div class="col-xs-10 sql_container">
        <div class="row">
            <div ui-ace="{
            require: ['ace/ext/language_tools'],
            onLoad : aceLoaded,
            onChange: aceChanged
            }"></div>
        </div>
        <div class="row">
            <span>注1：SQL支持FreeMarker模板，可采用参数动态过滤，如参数格式${START_TIME}，参数由指标操作产生传递。目前支持格式包括值类型、字符类型、时间类型。参数可指定默认值作为初始化展现要求。<br/>如：select column1,column2 from table where time >='${START_TIME}'</span>
            <br/>
            <br/>
            <span>注2：对于数据权限，支持SQL增加用户身份标识，即用户标识：${USER_ID}，角色标识：${ROLE_ID}，角色标识集合：${ROLE_LIST}。标识为用户、角色的ID值，业务表数据列可与其关联。<br/>如：select column1,column2 from table where role in ${ROLE_LIST}</span>
            <br/>
            <br/>
            <span>注3：复杂情况可结合FreeMarker语法与指标传递的参数值生成动态SQL。<br/>&lt;#if param == 1&gt;   select * from abc  &lt;#elseif param == 2&gt;  select * from cde  &lt;#else&gt;  select * from efg  &lt;/#if&gt;</span>
        </div>
        <div class="row action_container">
            <a type="button" ng-click="executeSql()" class="btn btn-success pull-right">执行</a>
            <a type="button" ng-click="paramsSet()" class="btn btn-default pull-right">参数</a>
        </div>
    </div>
</div>
<div class="form-group">
    <label class="control-label col-xs-2">查询执行结果</label>
    <div class="col-xs-10 result_container">
        <div class="database_result_container">
            <table ng-show="executeData.length > 0">
                <thead>
                    <th ng-repeat="c in dataColumns">{{ c }}
                    </th>
                </thead>
                <tbody>
                <tr ng-repeat="d in executeData">
                    <td ng-repeat="c in dataColumns">{{ d[dataColumns.indexOf(c)] }}</td>
                </tr>
                </tbody>
            </table>
            <span ng-show="executeData.length == 0">无数据</span>
        </div>
    </div>
</div>
<div class="form-group">
    <label class="control-label col-xs-2">模型列映射</label>
    <div class="col-xs-10">
        <table class="editable_table">
            <thead>
            <tr>
                <th>数据模型编码</th>
                <th>数据模型名称</th>
                <th>数据列名称</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="column in dataset_defines.DataColumnsMap">
                <td>{{column.Code}}</td>
                <td>{{column.Name}}</td>
                <td>
                    <select ng-options="c as c for c in dataColumns" class="form-control"
                            required ng-model="column.Column"></select>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>